function getContent(Package, version, path) {
    //从 github 上获取数据
    return fetch(`https://cdn.jsdelivr.net/npm/${Package}${version ? "@" + version : ""}/${path}`, { cache: "no-store" }).then((res) => res.text());
}

function getVersion(Package) {
    return fetch(`https://data.jsdelivr.com/v1/package/npm/${Package}`)
        .then((res) => res.json())
        .then((res) => res.versions);
}
function getTree(Package, Version) {
    return fetch(`https://data.jsdelivr.com/v1/package/npm/${Package}@${Version}`)
        .then((res) => res.json())
        .then((res) => res.files);
}
export { getContent, getVersion, getTree };
